package com.znjc.iot.controller;

import com.alibaba.fastjson2.JSONObject;
import com.znjc.iot.websocket.CustomizedWebSocketClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Controller
@RequestMapping(value = "/socket")
public class WebSocketController {

    @Autowired
    private CustomizedWebSocketClient socketClient;

    @ResponseBody
    @PostMapping(value = "/message")
    public void getSocketMessage(HttpServletRequest request) throws IOException {
        socketClient.send("111111");
    }
}
